(library (custom-exceptions)
  (export make-lookup-error)
  (import (except (rnrs base) error)
          (only (guile)
                lambda* λ
                record-constructor)
          (ice-9 exceptions))

  (define make-lookup-error
    ;; record-constructor is a procedure, which will return the
    ;; constructor for any record.
    (record-constructor
     ;; Create an exception type, which is a record. This record has a
     ;; constructor, which we can name using define for example.
     (make-exception-type
      ;; name of the new exception type
      '&lookup-error
      ;; parent exception type
      &programming-error
      ;; list of values the constructor of the exception takes and their
      ;; names in the record
      '(key)))))
